namespace ghost
{
	/**一直跟随owner角色位置的无深度物体*/
    export class NoDepthObj extends ObjBase
    {	
		protected resetingSts():void
		{			
			let s= this;
			if(s._sts == StsType.DEATH)
			{
				s.del();
			}
			// if(s._owner)
			// 	(<GameRole>s._owner).subObjStsEnd(s);			
		}		
		public worldPosSet():void
		{			
			let s= this;
			let o:GameRole;
            o = s._owner?(<GameRole>s._owner):s;
			if(s.isSceneLayer())
			{
				// if(s.enabled3D)
				// 	s.d3WorldPosSet(s._absX,s._absY, s._absZ);
				// else
				// {
					s._skin.x = o.absX - s._scene.mapX;
					s._skin.y = o.absY - s._absZ - s._scene.mapY;
				// }
			}
			// else if(s._layerType == game.LayerType.DEF)
            // {
            //     s._skin.x = o._absX;
            //     s._skin.y = o._absY - s._owner._absZ;
            // }			
			else
			{				
				s._skin.x = s._absX;
				s._skin.y = s._absY - s._absZ;								
			}		
		}
		/**是否在视图内*/		
		public isInVisRect():boolean
		{
			let s= this;
			if(s._owner)
				return s._owner._visible;			
			return super.isInVisRect();			
        }
        public exitLoop(t:number,index:number):void
		{				
			let s= this;			
			if(s._rateLoopEnabled)
			{	
				s._skinPart.loop(t);
			}			
			s.worldPosSet();
        }		
		public enterLoop(t: number, index: number): void 
		{
			let s = this;			
			//nodepth以外物体的enterLoop继承自AniRole
			if(s._roleType == RoleType.NO_DEPTH_OBJ)
			{
				if(s._skinPart.playEnd)								
					s.resetSts();
			}
			else
				AniRole.prototype.enterLoop.call(s, t, index);
		}	
		protected posCheck():void
		{
			let s = this;
			let o = s.getOwner();
			if(s._oldAbsX != o.absX || s._oldAbsY != o.absY)
			{
				s._posChanged = true;
				s.posChange();
				s._oldAbsX = s._absX;
				s._oldAbsY = s._absY;
			}
		}	
    }
}